﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Gao.Poker.Domain;
using Gao.Poker.Services;

namespace Gao.Poker.Command
{
    public class ProductSaveCommand : BaseCommand
    {
        private readonly Action<Boolean, Product> _action;

        public ProductSaveCommand(Action<Boolean, Product> action)
        {
            _action = action;
        }

        public override void Execute(object parameter)
        {
            var product = parameter as Product;
            var productService = new ProductService();
            var result = productService.Save(product);

            if (_action != null)
            {
                _action(result != null, result);
            }
        }
    }
}
